<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
    
</head>
<body>
    <div id="app">
        <p>
            学生姓名<input type="text" v-model="newstudents.name"/>
            学生年龄<input type="number" v-model="newstudents.age"/>
            <button @click="add">添加</button>
        </p>
        <h1>{{title}}</h1>
       <ul>
           <li v-for="(item,id) in students":key="id">
            学生姓名{{item.name}}
            学生年龄{{item.age}}
           </li>
         
       </ul>

    </div>
    
    <script>
       var vm= new Vue({
          el: '#app',
          data: {
                title:"学生管理系统",
                newstudents:{
                    name:"",
                    age:""

                },
                students:[
                    {name:"xiao ming", age:"20"},
                    {name:"xiao hong", age:"18"},
                    {name:"xiao li", age:"220"},
                ],
},
methods:{
add(){
    this.students.push({
        name: this.newstudents.name,
        age: this.newstudents.age ,
    })
}
}
       });
    </script> 
</body>
</html>